<?php
class Login extends CI_Controller
{
	public function __construct()
  	{
	    parent::__construct();
	    $this->load->model('loginmodel');
  	}
	
	public function index()
 	{
	  $this->load->helper('form');
	  $this->load->library('form_validation');
	  
	  $data['title'] = 'Login';
	  
	  $this->form_validation->set_rules('accout',   'Account',  'required');
	  $this->form_validation->set_rules('password', 'Password', 'required');
	  
	  if ($this->form_validation->run() === FALSE)
	  {
//	    $this->load->view('templates/header', $data);  
	    $this->load->view('login');
//	    $this->load->view('templates/footer');
	  }
	  else
	  {
	    $isLoginOk = $this->loginmodel->login();
	    if ($isLoginOk == TRUE)
	    {
	    	$this->load->view('success');
	    }
	    else 
	    {
	    	$this->load->view('login');
	    }
	    
	  }
	}
}